﻿function DeleteNote(noteID) {
    var texTrans = $.iHouse.deleteNoteDialog.confirmationtext; ;
    var text = texTrans.replace("{0}", noteID);
    var divString = "<div id='dialog' title='" + $.iHouse.deleteNoteDialog.titletext + "'><p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span>"
            + text + "</p></div>";

    function okClick() {
        var absoluteUrl = Sys.loader.applicationPath + "Note/Delete/";
        var url = absoluteUrl + noteID;

        $.post(url, deleteCallback);

        $(this).dialog('close');
    };

    function cancelClick() {
        $(this).dialog('close');
    };

    var dialogButton = {};
    dialogButton[$.iHouse.button.oktext] = okClick;
    dialogButton[$.iHouse.button.canceltext] = cancelClick;

    $(divString).dialog({
        bgiframe: true,
        resizable: false,
        height: 140,
        width: 350,
        modal: true,
        overlay: {
            backgroundColor: '#000',
            opacity: 0.5
        },
        buttons: dialogButton
    });

    function deleteCallback(result) {
        if (result.Status == 'succeed')
            window.parent.location.reload();
    }   
}

function InitNoteModals() {
    $('.noteEdit').each(function () {
        $(this).colorbox({ iframe: true, width: "550px", height: "600px" });
    })
}